// 菜单数据配置
export const menuData = [
  {
    name: '仪表板',
    path: '/dashboard',
    icon: 'Odometer',
    roles: ['Student', 'ClubAdmin', 'SuperAdmin'],
    children: []
  },
  {
    name: '发现中心',
    path: '/discovery',
    icon: 'Search',
    roles: ['Student', 'ClubAdmin', 'SuperAdmin'],
    children: [
      {
        name: '社团广场',
        path: '/discovery/club-square',
        icon: 'OfficeBuilding',
        roles: ['Student', 'ClubAdmin', 'SuperAdmin'],
        children: []
      },
      {
        name: '活动中心',
        path: '/discovery/activity-center',
        icon: 'Calendar',
        roles: ['Student', 'ClubAdmin', 'SuperAdmin'],
        children: []
      }
    ]
  },
  {
    name: '我的工作台',
    path: '/my-workbench',
    icon: 'Briefcase',
    roles: ['Student', 'ClubAdmin', 'SuperAdmin'],
    children: [
      {
        name: '我的社团',
        path: '/my-workbench/my-clubs',
        icon: 'OfficeBuilding',
        roles: ['Student', 'ClubAdmin', 'SuperAdmin'],
        children: []
      },
      {
        name: '我的活动',
        path: '/my-workbench/my-activities',
        icon: 'Calendar',
        roles: ['Student', 'ClubAdmin', 'SuperAdmin'],
        children: []
      },
      {
        name: '我的申请',
        path: '/my-workbench/my-applications',
        icon: 'Document',
        roles: ['Student', 'ClubAdmin', 'SuperAdmin'],
        children: []
      }
    ]
  },
  {
    name: '社团管理',
    path: '/club-management',
    icon: 'Setting',
    roles: ['ClubAdmin', 'SuperAdmin'],
    children: [
      {
        name: '信息维护',
        path: '/club-management/profile',
        icon: 'Edit',
        roles: ['ClubAdmin', 'SuperAdmin'],
        children: []
      },
      {
        name: '成员管理',
        path: '/club-management/members',
        icon: 'User',
        roles: ['ClubAdmin', 'SuperAdmin'],
        children: []
      },
      {
        name: '活动管理',
        path: '/club-management/events',
        icon: 'Calendar',
        roles: ['ClubAdmin', 'SuperAdmin'],
        children: []
      },
      {
        name: '财务管理',
        path: '/club-management/finances',
        icon: 'Money',
        roles: ['ClubAdmin', 'SuperAdmin'],
        children: []
      },
      {
        name: '公告发布',
        path: '/club-management/announcements',
        icon: 'Bell',
        roles: ['ClubAdmin', 'SuperAdmin'],
        children: []
      }
    ]
  },
  {
    name: '平台管理',
    path: '/platform-management',
    icon: 'Tools',
    roles: ['SuperAdmin'],
    children: [
      {
        name: '用户管理',
        path: '/platform-management/user-management',
        icon: 'User',
        roles: ['SuperAdmin'],
        children: []
      },
      {
        name: '社团管理',
        path: '/platform-management/club-management',
        icon: 'OfficeBuilding',
        roles: ['SuperAdmin'],
        children: [
          {
            name: '社团列表',
            path: '/platform-management/club-management/club-list',
            icon: 'List',
            roles: ['SuperAdmin'],
            children: []
          },
          {
            name: '创建审批',
            path: '/platform-management/club-management/creation-approvals',
            icon: 'Check',
            roles: ['SuperAdmin'],
            children: []
          },
          {
            name: '活动审批',
            path: '/platform-management/club-management/event-approval',
            icon: 'Calendar',
            roles: ['SuperAdmin'],
            children: []
          }
        ]
      },
      {
        name: '全局公告',
        path: '/platform-management/global-announcements',
        icon: 'Bell',
        roles: ['SuperAdmin'],
        children: []
      },
      {
        name: '系统设置',
        path: '/platform-management/system-settings',
        icon: 'Setting',
        roles: ['SuperAdmin'],
        children: [
          {
            name: '角色与权限',
            path: '/platform-management/system-settings/roles-permissions',
            icon: 'Key',
            roles: ['SuperAdmin'],
            children: []
          },
          {
            name: '分类管理',
            path: '/platform-management/system-settings/category-management',
            icon: 'Menu',
            roles: ['SuperAdmin'],
            children: []
          }
        ]
      }
    ]
  },
  {
    name: '数据洞察',
    path: '/analytics',
    icon: 'TrendCharts',
    roles: ['ClubAdmin', 'SuperAdmin'],
    children: [
      {
        name: '本社团数据',
        path: '/analytics/my-club-analytics',
        icon: 'DataAnalysis',
        roles: ['ClubAdmin', 'SuperAdmin'],
        children: []
      },
      {
        name: '全平台数据',
        path: '/analytics/platform-analytics',
        icon: 'DataBoard',
        roles: ['SuperAdmin'],
        children: []
      }
    ]
  }
]

// 根据用户角色过滤菜单
export function getMenuByRole(userRole) {
  function filterMenu(menuItems) {
    return menuItems.filter(item => {
      if (item.roles.includes(userRole)) {
        if (item.children && item.children.length > 0) {
          item.children = filterMenu(item.children)
        }
        return true
      }
      return false
    })
  }
  
  return filterMenu(menuData)
}

// 获取所有路由路径（用于路由配置）
export function getAllRoutes(menuItems = menuData) {
  const routes = []
  
  menuItems.forEach(item => {
    if (item.path) {
      routes.push(item.path)
    }
    if (item.children && item.children.length > 0) {
      routes.push(...getAllRoutes(item.children))
    }
  })
  
  return routes
}
